package lesson01;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TestPanel {
    public static void main(String[] args) {
        Frame frame=new Frame("测试窗口");
        Panel panel=new Panel();
        //设置布局
        frame.setLayout(null);
        //坐标
        frame.setBounds(300,300,500,500);
        frame.setBackground(new Color(60,60,60));
        //设置Panel坐标，相当于frame
        panel.setBounds(50,50,400,400);
        panel.setBackground(new Color(100,100,100));
        //frame.add(panel);
        frame.add(panel);
        //设置可见性
        frame.setVisible(true);
        //监听事件，监听窗口关闭事件
        frame.addWindowListener(new WindowAdapter(){
            //窗口点击关闭时需要去做的事情
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

    }
}
